package cn.ilikes.webs.webs;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import cn.ilikes.tools.logs.Loggerfactory;
import cn.ilikes.webs.bases.AjaxJsonAction;
import cn.ilikes.webs.services.IWebUserService;

@Component("LoginAction")
@Scope("prototype")
public class LoginAction extends AjaxJsonAction {

	private static Logger logger = Loggerfactory.instance(LoginAction.class);

	@Resource(name = IWebUserService.SPRING_SERVICE)
	private IWebUserService webUserService;

	private String userId;

	private String passwd;

	public String login() throws Exception {
		try {
			result = webUserService.login(userId, passwd);
		} catch (Exception e) {
			Loggerfactory.error(logger, e);
			result = RESULT_EXCEPTION_ERROR;
		}

		return null;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}

}
